package cn.lzd.mr.case7;

import org.apache.hadoop.io.WritableComparable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

/**
 * Created by lzd on 2018/6/5.
 */
public class Bean2 implements WritableComparable<Bean2> {

    public Bean2() {
    }

    public Bean2(String orderid, String userid, String name, int age, String stageName, String filename) {
        this.orderid = orderid;
        this.userid = userid;
        this.name = name;
        this.age = age;
        this.stageName = stageName;
        this.filename = filename;
    }

    private String orderid;
    private String userid;
    private String name;
    private int age;
    private String stageName;
    private String filename;

    @Override
    public void write(DataOutput dataOutput) throws IOException {
        dataOutput.writeUTF(this.orderid);
        dataOutput.writeUTF(this.userid);
        dataOutput.writeUTF(this.name);
        dataOutput.writeInt(this.age);
        dataOutput.writeUTF(this.stageName);
        dataOutput.writeUTF(this.filename);
    }

    @Override
    public void readFields(DataInput dataInput) throws IOException {
        this.orderid = dataInput.readUTF();
        this.userid = dataInput.readUTF();
        this.name = dataInput.readUTF();
        this.age = dataInput.readInt();
        this.stageName = dataInput.readUTF();
        this.filename = dataInput.readUTF();
    }

    public void setFilename(String filename) {
        this.filename = filename;
    }

    public String getFilename() {
        return filename;
    }

    public void setOrderid(String orderid) {
        this.orderid = orderid;
    }

    public void setUserid(String userid) {
        this.userid = userid;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public void setStageName(String stageName) {
        this.stageName = stageName;
    }

    public String getOrderid() {
        return orderid;
    }

    public String getUserid() {
        return userid;
    }

    public String getName() {
        return name;
    }

    public int getAge() {
        return age;
    }

    public String getStageName() {
        return stageName;
    }

    @Override
    public String toString() {
        return orderid + '\t' + userid + '\t' + name + '\t' + age + '\t' + stageName + '\t' + filename + '\t';

    }

    @Override
    public int compareTo(Bean2 o) {
        System.out.println("====================================map第一次排序开始-结束====================================");
        return o.getUserid().compareTo(this.getUserid()) == 0 ? o.getFilename().compareTo(this.getFilename()) : o.getUserid().compareTo(this.getUserid());

    }


}
